package com.gitee.wsl.transform.encode.pinyin.trie

import com.gitee.wsl.transform.encode.pinyin.interval.Interval
import com.gitee.wsl.transform.encode.pinyin.interval.Intervalable

/**
 * Contains a matched term and its associated payload data.
 *
 * @param <T> Type of the wrapped payload-data.
 * @author Daniel Beck
</T> */
class PayloadEmit<T>
/**
 * Created a PayloadEmit
 *
 * @param start   Start of the matched search term.
 * @param end     End of the matched search term.
 * @param keyword Keyword that matched.
 * @param payload Emitted payload data.
 */(
    start: Int, end: Int, val keyword: String,
    /**
     * Returns the payload associated to this emit.
     *
     * @return the associated payload
     */
    val payload: T?
) : Interval(start, end), Intervalable {

     override fun toString(): String {
        return super.toString() + "=" + this.keyword + (if (this.payload != null) "->" + this.payload else "")
    }

}
